<div id="<?php echo $this->panel->getDivID() ?>">
    <div class="RM_advancedsearch_persons_container">
        <table width="90%" border="0" cellpadding="0" cellspacing="0" align="center" class="RM_advancedsearch_formrow">
            <tr>
                <td class="RM_advancedsearch_leftcolumn">
                    <?php echo $this->_translate->_('User.ExcursionPrices.AdvancedSearch','NumberAdults');?>
                </td>
                <td>
                    <select id="search[adults]" name="search[adults]">
                        <option value="1"><?php echo $this->_translate->_('User.ExcursionPrices.AdvancedSearch','Loading');?></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="RM_advancedsearch_leftcolumn">
                    <?php echo $this->_translate->_('User.ExcursionPrices.AdvancedSearch','NumberChildren');?>
                </td>
                <td>
                    <select id="search[children]" name="search[children]">
                        <option value="0"><?php echo $this->_translate->_('User.ExcursionPrices.AdvancedSearch','Loading');?></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="RM_advancedsearch_leftcolumn">
                    <?php echo $this->_translate->_('User.ExcursionPrices.AdvancedSearch','NumberInfants');?>
                </td>
                <td>
                    <select id="search[infants]" name="search[infants]">
                        <option value="0"><?php echo $this->_translate->_('User.ExcursionPrices.AdvancedSearch','Loading');?></option>
                    </select>
                </td>
            </tr>
        </table>
    </div>
</div>
<script type="text/javascript">

// get the person global values
var conn = new Ext.data.Connection();
var request = {
    url: RM.Common.AssembleURL({
        controller : 'ExcursionPrices',
        action: 'getpersonsJson'
    }),
    method: 'POST',
    success: function(responseObject) {
        var json = Ext.util.JSON.decode(responseObject.responseText);

        var AdultSelect = document.getElementById("search[adults]");
        var ChildrenSelect = document.getElementById("search[children]");
        var InfantSelect = document.getElementById("search[infants]");

        for (var m = 0; m < json.length; m++){
            if (json[m].name=="max_adults"){
                AdultSelect.options[0].text = "1";
                for (var i = 1; i < parseInt(json[m].value); i++){
                    AdultSelect.options[AdultSelect.options.length] = new Option(i+1, i+1);
                }
            }
            if (json[m].name=="max_children"){
                ChildrenSelect.options[0].text = "0";
                if (parseInt(json[m].value)>0){
                    for (var i = 1; i < parseInt(json[m].value)+1; i++){
                        ChildrenSelect.options[ChildrenSelect.options.length] = new Option(i, i);
                    }
                }
            }
            if (json[m].name=="max_infants"){
                InfantSelect.options[0].text = "0";
                if (parseInt(json[m].value)>0){
                    for (var i = 1; i < parseInt(json[m].value)+1; i++){
                        InfantSelect.options[InfantSelect.options.length] = new Option(i, i);
                    }
                }
            }
        }

        if(typeof(RM_advanced_search_form_items) !== 'undefined') {
            RM_advanced_search_form_items.push('search[adults]');
            RM_advanced_search_form_items.push('search[children]');
            RM_advanced_search_form_items.push('search[infants]');
        }

    },
    failure: function(){
        document.getElementById('RM_dateselector_message').innerHTML = "<?php echo $this->_translate->_('User.DatePicker','AJAXFailure');?>";
    }
};
conn.request(request);
</script>